#!/usr/bin/env perl

#
# Copyright (c) 2002-2004 Eric Wallengren
# This file is part of the Continuous Automated Build and Integration
# Environment (CABIE)
#
# CABIE is distributed under the terms of the GNU General Public
# License version 2 or any later version.  See the file COPYING for copying
# permission or http://www.gnu.org.
#
# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR
# IMPLIED, without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  ANY USE IS AT YOUR OWN RISK.
#
# Permission to modify the code and to distribute modified code is granted,
# provided the above notices are retained, and a notice that the code was
# modified is included with the above copyright notice.
#``

BEGIN {
    push @INC, "lib";
    push @INC, "../lib";
    push @INC, "../../lib";
}

use Sys::Hostname;
use Getopt::Std;

my $hostname = hostname();
$hostname    =~ s/\.[a-zA-Z0-9\n]+//g;
$hostname    =~ s/-//g;

my $ospackage;

if ($ =~ /MSWin32/) {
    $ospackage = "winsys";
} else {
    $ospackage = "unixsys";
}

require "$ospackage.pm";
require "$hostname.pm";

my $os   = new $ospackage;
my $conf = new $hostname;

my $sqlquery;

my @sqlarray;

my %options;
my $job;
my $file;

getopts('n:f:', \%options);

$file = $options{f};
$job  = $options{n};

if (!defined($file) || !defined($job)) {
    usage();
}

open F, ">$file" || die "Can't open file";

$blink = "http://ultra10:8080/\@md=d&cd=//depot/main/&c=OUI\@%s?ac=22";

@filelist = `c4 have`;

foreach $entry (sort @filelist) {
    ($left, $right) = split(/ - /, $entry);
    ($file, $ver) = split(/\#/, $left);
    $string = sprintf("$blink", $file);
    print F "<A HREF=$string>$left</A><br>\n";
}
    
sub usage {

    print "-f file -n job\n";
    exit 1;

}
